<script setup>
import { ref , watch} from 'vue'
const totalCount = ref(100)
const msg=ref('hello')
// 侦听一个响应式数据
// watch(totalCount, (newValue, oldValue) => {
//   console.log('totalCount',{newValue, oldValue});
// })
// 支持同时侦听多个值(了解)
watch([totalCount, msg], (newValue, oldValue) => {
  console.log('totalCount',{newValue, oldValue});
})

</script>
<template>
  <!-- 结构 template 中会自动解包，所以无需写 .value-->
<h1>{{ totalCount }}</h1>
<button @click="totalCount++">点击累加</button>
<button @click="msg+='~'">{{ msg }}</button>

</template>
<style></style>
